<!doctype html>
<html>

<head>
	<meta charset="UTF-8">
	<meta name="copyright" content="www.apicloud.com" />
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<title>舆情工作平台登陆</title>
	<link rel="stylesheet" type="text/css" href="../css/api.css" />
	<style>
		html {
			height: 100%;
		}

		body {
			height: 100%;
			width: 100%;
			background-image: url(../res/bg.png);
			background-size: 100%;
		}

		input {
			height: 50px;
			font-size: 18px;
			color: #8E8C8C;
			width: 80%;
		}

		input::-webkit-input-placeholder {
			color: #ccc;
		}

		.top_logo {
			width: 90%;
			margin: 0 5%;
			height:30px;
		}

		.main_logo {
			width: 60%;
			margin: 0 20%;
		}

		.email,
		.passwd {
			/*margin-top: 3px;*/
			background: #fff;
		}

		.passwd img,
		.email img {
			vertical-align: top;
		}

		.item {
			width: 90%;
			margin: 0 5%;
			position: relative;
		}

		.email {
			-webkit-border-radius: 5px 5px 0px 0px;
			border: 1px solid #acacac;
		}

		.passwd {
			-webkit-border-radius: 0px 0px 5px 5px;
			border-right: 1px solid #acacac;
			border-left: 1px solid #acacac;
			border-bottom: 1px solid #acacac;
		}
		/*.email, .passwd, .btn {margin:3px 10px;}*/

		.btn {
			margin: 3px 10px;
		}

		.btn {
			background: #3A8B7A;
			color: #fff;
			height: 40px;
			text-align: center;
			line-height: 40px;
			font-size: 20px;
			margin-top: 20px;
			border-radius: 5px;
		}

		.email img {
			width: 25px;
			margin-top: 15px;
			margin-left: 10px;
			margin-right: 9px;
		}

		.passwd img {
			height: 25px;
			margin-top: 10px;
			margin-left: 10px;
			margin-right: 10px;
		}
		/* 底部样式 */

		.bottom {
			/*position: absolute;bottom: 0;*/
			width: 100%;
			text-align: center;
			/*padding-bottom: 20px;*/
			font-size: 12px;
		}

		.bottom>span {
			line-height: 26px;
			color: #999999;
			font-size: 1.2em;
		}

		.bottom>span>a {
			line-height: 26px;
			color: blue;
			font-size: 1.2em;
		}

		.bottom>span>a:hover {
			color: #999999;
		}

		input {
			outline: none;
		}
	</style>
</head>

<body>
	<div class="top">
		<div id="clear_2"></div>
		<div class="top_logo">
			<!-- <img src="../image/admin/top_logo.png" width="100%" /> -->
		</div>
		<div id="clear_3"></div>
		<div class="main_logo"><img src="../image/admin/main_logo.png" width="100%" /></div>
		<div id="clear_4"></div>
		<!---------------------------登陆信息输入框------------------------------------->
		<div class="item email">
			<img src="../image/admin/user.png" alt="">
			<input id="username" name="username" type="text" placeholder="输入手机号">
		</div>
		<div class="item passwd">
			<img src="../image/admin/password.png" alt="">
			<input id="password" name="password" type="password" placeholder="输入密码">
		</div>
		<!---------------------------登陆信息输入框------------------------------------->
		<div id="clear_5"></div>
		<div class="btn" tapmode="buyhover" onclick="goto_userLogin()">登 录</div>
	</div>
	<!---------------------------底部信息间距------------------------------------->
	<div id="clear"> </div>
	<!---------------------------底部信息间距------------------------------------->
	<!---------------------------底部信息------------------------------------->
	<div class="bottom">
		<!--			<span id="tel">联系电话：<a href="tel:0531-85196544">0531-85196544</a></span>-->
		<span id="copyright">Copyright© 2021 大众报业集团·大众网·舆情中心</span>
	</div>
	<!---------------------------底部信息------------------------------------->
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/alpenlicebe.js"></script>
<script type="text/javascript" src="../script/zepto.min.js"></script>
<script type="text/javascript" src="../script/hashes.min.js"></script>
<script type="text/javascript">
	function goto_CheckInfoFun() {
		var deviceId_t = Alpe_getLocalStorge("deviceId");
		var systemType_t = Alpe_getLocalStorge("systemType");
		if ('' == deviceId_t || '' == systemType_t) {
			var systemType = api.systemType;
			if ("ios" == api.systemType) {
				systemType = "iphone";
			}
			var MD5 = new Hashes.MD5;
			var deviceId = MD5.hex(api.deviceId);

			Alpe_setLocalStorge('deviceId', deviceId);
			Alpe_setLocalStorge('systemType', systemType);
		}
	}
	apiready = function() {
		api.setStatusBarStyle({
			style: 'dark'
		});
		goto_CheckInfoFun();
		api.hideProgress();
		/*监听keyback事件，防止android返回操作*/
		api.addEventListener({
			name: 'keyback'
		}, function(ret, err) {
			return;
		});
		//获取联系电话
		goto_getContactTelFun();

		//获取个div层之间的间距
		document.getElementById('clear_2').style.height = api.winHeight * 0.07 + "px";
		document.getElementById('clear_3').style.height = api.winHeight * 0.05 + "px";
		document.getElementById('clear_4').style.height = api.winHeight * 0.06 + "px";
		document.getElementById('clear_5').style.height = api.winHeight * 0.04 + "px";

		//获取底部信息间距 页面高度减去底部和顶部的高度再减去距底部的20得出间距高度
		var top_height = $api.dom('.top').offsetHeight;
		var bottom_height = $api.dom('.bottom').offsetHeight;
		var clear_height = api.winHeight - top_height - bottom_height - 20;
		document.getElementById('clear').style.height = clear_height + 'px';

		//从保存文件中获取相关信息

		var username = Alpe_getLocalStorge("username");
		var password = Alpe_getLocalStorge("password");
		if ('' != username && '' != password) {
			document.getElementById("username").value = username;
			document.getElementById("password").value = password;
			//setTimeout(function(){goto_userLogin();},100);
		}
	}

	/*获取联系电话*/
	function goto_getContactTelFun() {
		var url = Alpe_ApiUrl + 'r=login/getQbTel&v=1.0';
		console.log(url);
		api.ajax({
			url: url,
			method: 'get',
			cache: false,
			timeout: 30,
			dataType: 'json'
		}, function(ret, err) {
			if (ret) { //服务器成功返回数据，验证数据是否正确
				$("#tel").html('联系电话：<a href="tel:' + ret.tel + '">' + ret.tel + '</a>');
				$("#copyright").html(ret.copyright);
			}
		});
	}

	/*点击登录*/
	function goto_userLogin() {
		var username = $api.byId('username').value;
		var password = $api.byId('password').value;
		if ('' == username) {
			api.alert({
				title: '系统提示',
				msg: '请输入手机号'
			});
			return;
		}
		if ('' == password) {
			api.alert({
				title: '系统提示',
				msg: '请输入密码'
			});
			return;
		}

		var url = Alpe_ApiUrl + 'r=login/login&v=1.0' +
			'&username=' + username + '&password=' + password +
			'&device_number=' + Alpe_getLocalStorge("deviceId") +
			'&system_type=' + Alpe_getLocalStorge("systemType") +
			'&jpush=notification';
		//console.log(url);
		api.showProgress({
			style: 'default',
			animationType: 'fade',
			title: '登录验证中...',
			text: '请稍后...',
			modal: false
		});
		api.ajax({
			url: url,
			method: 'get',
			cache: false,
			timeout: 30,
			dataType: 'json'
		}, function(ret, err) {
			if (ret) {
				if (ret.success == '000') {
					Alpe_setLocalStorge('sys_userID', ret.access_token);
					Alpe_setLocalStorge('access_token', ret.access_token);
					Alpe_setLocalStorge('admin_id', ret.admin_id);
					Alpe_setLocalStorge('username', username);
					Alpe_setLocalStorge('password', password);
					api.removeEventListener({
						name: 'keyback'
					});
					/*注册一个事件   已成功登录*/
					api.sendEvent({
						name: 'Alpe_Event_UserLogin',
						extra: {
							keyID: 'alpenlicebe'
						}
					});
					api.hideProgress();
					api.closeWin();
				} else {
					api.alert({
						title: '错误提示',
						msg: ret.message
					});
					api.hideProgress();
				}
			} else {
				api.alert({
					title: '系统提示',
					msg: '网络链接超时，请返回重试'
				});
				api.hideProgress();
			}
		});
	}
</script>

</html>
